cmake_minimum_required(VERSION 3.12)
project(sqlite3_example)

# 设置C++标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# 设置CMP0074策略以使用<PackageName>_ROOT变量
if(POLICY CMP0074)
  cmake_policy(SET CMP0074 NEW)
endif()

# 定义SQLite3_ROOT变量，允许用户在CMake配置时传入路径
set(SQLITE3_ROOT "" CACHE PATH "Path to SQLite3")

# 手动设置包含目录
include_directories(${SQLITE3_ROOT}/include)

# 添加可执行文件
add_executable(sqlite3_example sqlite3_example.cpp)

# 为不同的配置设置链接库
target_link_libraries(sqlite3_example
    debug ${SQLITE3_ROOT}/lib/sqlite3d.lib
    optimized ${SQLITE3_ROOT}/lib/sqlite3.lib
)

# 设置Visual Studio调试环境变量，只添加SQLite3路径
set_target_properties(sqlite3_example PROPERTIES
    VS_DEBUGGER_ENVIRONMENT "PATH=${SQLITE3_ROOT}/bin")

# 设置example为启动项目
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT sqlite3_example)
